name: Tests 13 sprint

on:
  push:
    branches:
      - '**'
    tags:
      - '**'


jobs:
  test_config:
    runs-on: ubuntu-latest
    steps:
    - name: Set up GitHub Actions
      uses: actions/checkout@v2
    - name: Use Node.js 14.x
      uses: actions/setup-node@v1
      with:
        node-version: 14.x
    - name: Get testing lib
      run: set -eu && git clone --depth 1 https://github.com/Yandex-Practicum/web-autotest-public.git
    - name: Copy Makefile
      run: cp ./web-autotest-public/Makefile ./Makefile
    - name: Installing Dependencies
      run: npm i
    - name: Run test config
      run: make proj13-test-config

  test_endpoints:
    runs-on: ubuntu-latest
    steps:
    - name: Set up GitHub Actions
      uses: actions/checkout@v2
    - name: Use Node.js 14.x
      uses: actions/setup-node@v1
      with:
        node-version: 14.x
    - name: Start MongoDB
      uses: supercharge/mongodb-github-action@1.6.0
      with:
        mongodb-version: '4.4'
    - name: Get testing lib
      run: set -eu && git clone --depth 1 https://github.com/Yandex-Practicum/web-autotest-public.git
    - name: Copy Makefile
      run: cp ./web-autotest-public/Makefile ./Makefile
    - name: Run prepare-test-endpoints
      run: make proj13-prepare-test-endpoints
    - name: Installing Dependencies
      run: npm i
    - name: Installing wait-port
      run: npm install -g wait-port
    - name: Run server
      run: npm run start & wait-port -t 30000 localhost:3000
    - name: Run test config
      run: make proj13-test-endpoints
